<template>
  <div class="app-container">
    <el-form 
      :model="queryParams" 
      ref="queryForm" 
      size="small" 
      :inline="true" 
      v-show="showSearch" 
      class="api-search-form">
      <el-card shadow="hover" class="search-card">
        <el-row :gutter="24">
          <el-col :span="6">
            <el-form-item label="API名称">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入API名称"
          clearable
                prefix-icon="el-icon-search"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="分类ID">
        <el-input
          v-model="queryParams.categoryId"
          placeholder="请输入分类ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="请求方法">
              <el-select 
          v-model="queryParams.method"
                placeholder="请选择请求方法" 
                clearable 
                style="width: 100%">
                <el-option label="GET" value="GET"/>
                <el-option label="POST" value="POST"/>
                <el-option label="PUT" value="PUT"/>
                <el-option label="DELETE" value="DELETE"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="接口状态">
              <el-select 
                v-model="queryParams.status" 
                placeholder="请选择接口状态" 
          clearable
                style="width: 100%">
                <el-option label="上线" :value="1"/>
                <el-option label="下线" :value="0"/>
                <el-option label="维护" :value="2"/>
              </el-select>
      </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="6">
            <el-form-item label="接口地址">
        <el-input
          v-model="queryParams.url"
          placeholder="请输入接口地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="认证要求">
              <el-select 
                v-model="queryParams.authRequired" 
                placeholder="请选择认证要求" 
                clearable 
                style="width: 100%">
                <el-option label="是" :value="1"/>
                <el-option label="否" :value="0"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" style="text-align: right;">
            <el-form-item class="search-buttons">
              <el-button 
                type="primary" 
                icon="el-icon-search" 
                size="mini" 
                @click="handleQuery">搜索</el-button>
              <el-button 
                icon="el-icon-refresh" 
                size="mini" 
                @click="resetQuery">重置</el-button>
              <el-button 
                type="text" 
                size="mini" 
                @click="toggleAdvancedSearch">
                {{ showAdvanced ? '收起' : '展开' }}
                <i :class="[showAdvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down']" />
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24" v-show="showAdvanced">
          <el-col :span="6">
            <el-form-item label="每日限制">
              <el-input-number
          v-model="queryParams.dailyLimit"
                placeholder="每日调用限制"
                :min="0"
                style="width: 100%"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="QPS限制">
              <el-input-number
          v-model="queryParams.qpsLimit"
                placeholder="每秒请求数限制"
                :min="0"
                style="width: 100%"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>

    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span class="card-title">API信息列表</span>
        <el-button-group style="float: right;">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['interfaces:interfaceInfo:add']"
        >新增</el-button>
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['interfaces:interfaceInfo:edit']"
        >修改</el-button>
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['interfaces:interfaceInfo:remove']"
        >删除</el-button>
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['interfaces:interfaceInfo:export']"
        >导出</el-button>
        </el-button-group>
      </div>

      <el-table 
        v-loading="loading" 
        :data="interfaceInfoList" 
        @selection-change="handleSelectionChange"
        border
        stripe
        style="width: 100%"
        :header-cell-style="{background:'#f5f7fa'}"
        highlight-current-row>
        <el-table-column type="selection" width="55" align="center" fixed="left"/>
        <el-table-column label="API ID" align="center" prop="id" width="80" fixed="left"/>
        <el-table-column label="API名称" align="center" prop="name" min-width="120" show-overflow-tooltip />
        <el-table-column label="API描述" align="center" prop="description" min-width="180" show-overflow-tooltip />
        <el-table-column label="分类ID" align="center" prop="categoryId" width="100" />
        <el-table-column label="请求方法" align="center" prop="method" width="100">
          <template slot-scope="scope">
            <el-tag :type="scope.row.method === 'GET' ? 'success' : scope.row.method === 'POST' ? 'primary' : scope.row.method === 'PUT' ? 'warning' : 'danger'" size="mini">
              {{ scope.row.method }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="接口地址" align="center" prop="url" min-width="200" show-overflow-tooltip />
        <el-table-column label="状态" align="center" prop="status" width="120">
          <template slot-scope="scope">
            <el-tag :type="scope.row.status === 1 ? 'success' : scope.row.status === 0 ? 'danger' : 'warning'">
              {{ scope.row.status === 1 ? '上线' : scope.row.status === 0 ? '下线' : '维护' }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="请求参数" align="center" prop="requestParams" min-width="150" show-overflow-tooltip />
        <el-table-column label="返回示例" align="center" prop="responseExample" min-width="150" show-overflow-tooltip />
        <el-table-column label="每日限制" align="center" prop="dailyLimit" width="100" />
        <el-table-column label="QPS限制" align="center" prop="qpsLimit" width="100" />
        <el-table-column label="认证要求" align="center" prop="authRequired" width="100">
          <template slot-scope="scope">
            <el-tag :type="scope.row.authRequired === 1 ? 'danger' : 'success'" size="mini">
              {{ scope.row.authRequired === 1 ? '是' : '否' }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="备注" align="center" prop="remark" min-width="120" show-overflow-tooltip />
        <el-table-column label="操作" align="center" width="120" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['interfaces:interfaceInfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['interfaces:interfaceInfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>

    <!-- 添加或修改API信息对话框 -->
    <el-dialog 
      :title="title" 
      :visible.sync="open" 
      width="650px" 
      append-to-body
      :close-on-click-modal="false"
      :destroy-on-close="true"
      class="api-dialog">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px" size="small">
        <el-row :gutter="20">
          <el-col :span="12">
        <el-form-item label="API名称" prop="name">
              <el-input v-model="form.name" placeholder="请输入API名称" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="分类ID" prop="categoryId">
              <el-input v-model="form.categoryId" placeholder="请输入分类ID" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="请求方法" prop="method">
              <el-select v-model="form.method" placeholder="请选择请求方法" style="width: 100%">
                <el-option label="GET" value="GET"/>
                <el-option label="POST" value="POST"/>
                <el-option label="PUT" value="PUT"/>
                <el-option label="DELETE" value="DELETE"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接口状态" prop="status">
              <el-select v-model="form.status" placeholder="请选择接口状态" style="width: 100%">
                <el-option label="上线" :value="1"/>
                <el-option label="下线" :value="0"/>
                <el-option label="维护" :value="2"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="接口地址" prop="url">
              <el-input v-model="form.url" placeholder="请输入接口地址" clearable>
                <template slot="prepend">/</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="每日调用限制" prop="dailyLimit">
              <el-input-number v-model="form.dailyLimit" :min="0" controls-position="right" style="width: 100%" placeholder="请输入每日调用限制"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="QPS限制" prop="qpsLimit">
              <el-input-number v-model="form.qpsLimit" :min="0" controls-position="right" style="width: 100%" placeholder="请输入每秒请求数限制"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否需要认证" prop="authRequired">
              <el-switch
                v-model="form.authRequired"
                :active-value="1"
                :inactive-value="0"
                active-color="#13ce66"
                inactive-color="#ff4949"
                active-text="是"
                inactive-text="否">
              </el-switch>
        </el-form-item>
          </el-col>
          <el-col :span="24">
        <el-form-item label="API描述" prop="description">
              <el-input v-model="form.description" type="textarea" :rows="3" placeholder="请输入API描述" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="请求参数" prop="requestParams">
              <div class="param-table-container">
                <div class="param-table-header">
                  <el-button type="primary" size="mini" icon="el-icon-plus" @click="openParamDialog()">添加参数</el-button>
                </div>
                <el-table :data="paramsList" border style="width: 100%" size="small">
                  <el-table-column label="参数名" prop="name" min-width="120" />
                  <el-table-column label="传入位置" prop="location" width="100">
                    <template slot-scope="scope">
                      <el-tag size="mini" :type="getPositionType(scope.row.location)">
                        {{ getPositionLabel(scope.row.location) }}
                      </el-tag>
                    </template>
                  </el-table-column>
                  <el-table-column label="参数类型" prop="type" width="100" />
                  <el-table-column label="是否必需" width="80" align="center">
                    <template slot-scope="scope">
                      <el-tag size="mini" :type="scope.row.required ? 'danger' : 'info'">
                        {{ scope.row.required ? '是' : '否' }}
                      </el-tag>
                    </template>
                  </el-table-column>
                  <el-table-column label="示例值" prop="example" min-width="120" show-overflow-tooltip />
                  <el-table-column label="默认值" prop="default" min-width="120" show-overflow-tooltip />
                  <el-table-column label="可选值" min-width="150" show-overflow-tooltip>
                    <template slot-scope="scope">
                      {{ scope.row.enum ? scope.row.enum.join(' | ') : '' }}
                    </template>
                  </el-table-column>
                  <el-table-column label="参数说明" prop="description" min-width="150" show-overflow-tooltip />
                  <el-table-column label="操作" width="120" fixed="right">
                    <template slot-scope="scope">
                      <el-button
                        type="text"
                        icon="el-icon-edit"
                        size="mini"
                        @click="openParamDialog(scope.row, scope.$index)">
                        编辑
                      </el-button>
                      <el-button
                        type="text"
                        icon="el-icon-delete"
                        size="mini"
                        @click="handleDeleteParam(scope.$index)">
                        删除
                      </el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="返回示例" prop="responseExample">
              <el-input v-model="form.responseExample" type="textarea" :rows="4" placeholder="请输入JSON格式的返回示例" />
        </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入备注信息" />
        </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="submitForm" :loading="submitLoading">确 定</el-button>
        <el-button size="small" @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 参数编辑弹窗 -->
    <el-dialog
      :title="paramDialogTitle"
      :visible.sync="paramDialogVisible"
      width="500px"
      append-to-body
      :close-on-click-modal="false"
      :destroy-on-close="true">
      <el-form ref="paramForm" :model="paramForm" :rules="paramRules" label-width="100px" size="small">
        <el-form-item label="参数名" prop="name">
          <el-input v-model="paramForm.name" placeholder="请输入参数名" />
        </el-form-item>
        <el-form-item label="传入位置" prop="location">
          <el-select v-model="paramForm.location" placeholder="请选择传入位置" style="width: 100%">
            <el-option label="请求参数" value="query" />
            <el-option label="请求头" value="header" />
            <el-option label="请求体" value="body" />
            <el-option label="路径参数" value="path" />
          </el-select>
        </el-form-item>
        <el-form-item label="参数类型" prop="type">
          <el-select v-model="paramForm.type" placeholder="请选择参数类型" style="width: 100%">
            <el-option label="字符串" value="string" />
            <el-option label="数字" value="number" />
            <el-option label="布尔值" value="boolean" />
            <el-option label="对象" value="object" />
            <el-option label="数组" value="array" />
          </el-select>
        </el-form-item>
        <el-form-item label="是否必需" prop="required">
          <el-switch
            v-model="paramForm.required"
            :active-value="true"
            :inactive-value="false"
            active-text="是"
            inactive-text="否">
          </el-switch>
        </el-form-item>
        <el-form-item label="示例值" prop="example">
          <el-input v-model="paramForm.example" placeholder="请输入示例值" />
        </el-form-item>
        <el-form-item label="默认值" prop="default">
          <el-input v-model="paramForm.default" placeholder="请输入默认值" />
        </el-form-item>
        <el-form-item label="可选值" prop="enum">
          <el-select
            v-model="paramForm.enum"
            multiple
            filterable
            allow-create
            default-first-option
            placeholder="请输入可选值"
            style="width: 100%">
          </el-select>
        </el-form-item>
        <el-form-item label="参数说明" prop="description">
          <el-input v-model="paramForm.description" type="textarea" :rows="3" placeholder="请输入参数说明" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="submitParamForm">确 定</el-button>
        <el-button size="small" @click="cancelParamDialog">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listInterfaceInfo, getInterfaceInfo, delInterfaceInfo, addInterfaceInfo, updateInterfaceInfo } from "@/api/interfaces/interfaceInfo";

export default {
  name: "InterfaceInfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // API信息表格数据
      interfaceInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        description: null,
        categoryId: null,
        method: null,
        url: null,
        status: null,
        requestParams: null,
        responseExample: null,
        dailyLimit: null,
        qpsLimit: null,
        authRequired: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        name: [
          { required: true, message: "API名称不能为空", trigger: "blur" }
        ],
        categoryId: [
          { required: true, message: "分类ID不能为空", trigger: "blur" }
        ],
        method: [
          { required: true, message: "请求方法(GET/POST/PUT/DELETE)不能为空", trigger: "blur" }
        ],
        url: [
          { required: true, message: "接口地址不能为空", trigger: "blur" }
        ],
      },
      submitLoading: false,
      showAdvanced: false,
      paramsList: [], // 请求参数列表
      // 参数弹窗相关
      paramDialogVisible: false,
      paramDialogTitle: '',
      editingParamIndex: -1,
      paramForm: {
        name: '',
        location: 'query',
        type: 'string',
        required: false,
        example: '',
        default: '',
        enum: [],
        description: ''
      },
      paramRules: {
        name: [
          { required: true, message: '参数名不能为空', trigger: 'blur' }
        ],
        location: [
          { required: true, message: '请选择传入位置', trigger: 'change' }
        ],
        type: [
          { required: true, message: '请选择参数类型', trigger: 'change' }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询API信息列表 */
    getList() {
      this.loading = true;
      
      // 创建一个干净的查询对象，避免嵌套参数
      const query = {};
      
      // 处理业务查询参数
      if (this.queryParams.name) query.name = this.queryParams.name;
      if (this.queryParams.description) query.description = this.queryParams.description;
      if (this.queryParams.categoryId) query.categoryId = this.queryParams.categoryId;
      if (this.queryParams.method) query.method = this.queryParams.method;
      if (this.queryParams.url) query.url = this.queryParams.url;
      if (this.queryParams.status !== null && this.queryParams.status !== undefined) query.status = this.queryParams.status;
      if (this.queryParams.requestParams) query.requestParams = this.queryParams.requestParams;
      if (this.queryParams.responseExample) query.responseExample = this.queryParams.responseExample;
      if (this.queryParams.dailyLimit) query.dailyLimit = this.queryParams.dailyLimit;
      if (this.queryParams.qpsLimit) query.qpsLimit = this.queryParams.qpsLimit;
      if (this.queryParams.authRequired !== null && this.queryParams.authRequired !== undefined) query.authRequired = this.queryParams.authRequired;
      
      // 直接添加分页参数（不要放在params中嵌套）
      query.pageNum = this.queryParams.pageNum;
      query.pageSize = this.queryParams.pageSize;
      
      console.log('分页请求参数:', query);
      
      // 发送包含分页参数的请求
      listInterfaceInfo(query).then(response => {
        this.interfaceInfoList = response.rows || [];
        this.total = response.total || 0;
        this.loading = false;
      }).catch(error => {
        console.error('获取数据失败:', error);
        this.loading = false;
        this.$message.error('获取数据失败，请刷新页面重试');
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        description: null,
        categoryId: null,
        method: null,
        url: null,
        status: null,
        delFlag: null,
        requestParams: null,
        responseExample: null,
        dailyLimit: null,
        qpsLimit: null,
        authRequired: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.paramsList = [];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加API信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getInterfaceInfo(id).then(response => {
        this.form = response.data;
        // 解析请求参数
        if (this.form.requestParams) {
          try {
            const requestParamsObj = JSON.parse(this.form.requestParams);
            this.paramsList = requestParamsObj.params || [];
          } catch (e) {
            console.error('解析请求参数失败:', e);
            this.$message.error('解析请求参数失败');
          }
        }
        this.open = true;
        this.title = "修改API信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.submitLoading = true;
          // 处理请求参数
          const requestParamsObj = {
            params: this.paramsList,
            rate_limit: {
              qps: this.form.qpsLimit || 10,
              day_limit: this.form.dailyLimit || 10000
            },
            content_type: "application/json",
            auth_required: this.form.authRequired === 1
          };
          this.form.requestParams = JSON.stringify(requestParamsObj);
          
          if (this.form.id != null) {
            updateInterfaceInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.submitLoading = false;
            });
          } else {
            addInterfaceInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.submitLoading = false;
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除API信息编号为"' + ids + '"的数据项？').then(function() {
        return delInterfaceInfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('interfaces/interfaceInfo/export', {
        ...this.queryParams
      }, `interfaceInfo_${new Date().getTime()}.xlsx`)
    },
    toggleAdvancedSearch() {
      this.showAdvanced = !this.showAdvanced;
    },
    // 获取传入位置标签类型
    getPositionType(position) {
      const types = {
        'header': 'warning',
        'query': 'success',
        'body': 'primary',
        'path': 'danger'
      }
      return types[position] || 'info'
    },
    // 获取传入位置显示文本
    getPositionLabel(position) {
      const labels = {
        'header': '请求头',
        'query': '请求参数',
        'body': '请求体',
        'path': '路径参数'
      }
      return labels[position] || position
    },
    // 打开参数编辑弹窗
    openParamDialog(row, index) {
      this.paramDialogVisible = true
      this.paramDialogTitle = row ? '编辑参数' : '添加参数'
      this.editingParamIndex = index
      
      if (row) {
        this.paramForm = JSON.parse(JSON.stringify(row))
      } else {
        this.paramForm = {
          name: '',
          location: 'query',
          type: 'string',
          required: false,
          example: '',
          default: '',
          enum: [],
          description: ''
        }
      }
    },
    // 取消参数编辑
    cancelParamDialog() {
      this.paramDialogVisible = false
      this.editingParamIndex = -1
      this.paramForm = {
        name: '',
        location: 'query',
        type: 'string',
        required: false,
        example: '',
        default: '',
        enum: [],
        description: ''
      }
    },
    // 提交参数表单
    submitParamForm() {
      this.$refs.paramForm.validate(valid => {
        if (valid) {
          const paramData = JSON.parse(JSON.stringify(this.paramForm))
          if (this.editingParamIndex > -1) {
            // 编辑现有参数
            this.$set(this.paramsList, this.editingParamIndex, paramData)
          } else {
            // 添加新参数
            this.paramsList.push(paramData)
          }
          this.paramDialogVisible = false
          this.editingParamIndex = -1
        }
      })
    },
    // 删除参数
    handleDeleteParam(index) {
      this.$confirm('是否确认删除该参数？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.paramsList.splice(index, 1)
        this.$message.success('删除成功')
      }).catch(() => {})
    }
  }
};
</script>

<style lang="scss" scoped>
.api-search-form {
  .search-card {
    margin-bottom: 20px;
    ::v-deep .el-card__body {
      padding: 15px 20px 0;
    }
  }
  ::v-deep .el-form-item {
    margin-bottom: 15px;
    .el-form-item__label {
      font-weight: normal;
      color: #606266;
    }
    .el-input__inner {
      border-radius: 4px;
    }
  }
  .el-button {
    margin-left: 8px;
    &:first-child {
      margin-left: 0;
    }
  }
  .search-buttons {
    margin-bottom: 15px;
  }
  ::v-deep .el-card {
    border-radius: 4px;
    border: 1px solid #ebeef5;
    background-color: #fff;
    color: #303133;
    transition: .3s;
    &:hover {
      box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
    }
  }
  ::v-deep .el-select {
    width: 100%;
  }
  ::v-deep .el-input-number {
    width: 100%;
  }
}

.box-card {
  margin-bottom: 20px;
  .card-title {
    font-size: 15px;
    font-weight: bold;
  }
  ::v-deep .el-card__header {
    padding: 10px 20px;
    border-bottom: 1px solid #ebeef5;
  }
}

.api-dialog {
  ::v-deep .el-dialog__body {
    padding: 20px 30px;
    max-height: calc(90vh - 110px);
    overflow-y: auto;
  }
  ::v-deep .el-dialog__header {
    padding: 15px 20px;
    border-bottom: 1px solid #dcdfe6;
    .el-dialog__title {
      font-size: 16px;
      font-weight: bold;
    }
  }
  ::v-deep .el-form-item__label {
    font-weight: 500;
  }
  ::v-deep .el-input-number .el-input__inner {
    text-align: left;
  }
}

.param-table-container {
  .param-table-header {
    margin-bottom: 10px;
    text-align: right;
  }
  
  ::v-deep .el-table {
    margin-bottom: 10px;
    
    .el-table__header th {
      background-color: #f5f7fa;
      color: #606266;
      font-weight: 500;
    }
    
    .el-input__inner,
    .el-select__input {
      height: 28px;
      line-height: 28px;
    }
    
    .el-button--mini {
      padding: 3px 8px;
    }
  }
}
</style>
